package controllers

import (
	"encoding/json"
	"mygolang/utils"
	"mygolang/models"

	beego "github.com/beego/beego/v2/server/web"
)

// LoginController provides login/logout functions
type LoginController struct {
	beego.Controller
}

// Login login api
// @Title Login
// @Description login
// @Param  body  body  models.LoginModel  true  "login info"
// @Success 200
// @router /login [post]
func (that *LoginController) Login() string {
	var info models.LoginModel
	json.Unmarshal(that.Ctx.Input.RequestBody, &info)
	token := utils.CreateToken(&info)

	return token
}
